
/** 日期格式化/判断浏览器内核/pc与移动/是否是微信浏览器
 * @author wddsl
 * @param {*} 
 * @returns 
 */
function getDate(dateTimeStamp){
	var minute = 1000 * 60;
	var hour = minute * 60;
	var day = hour * 24;
	var halfamonth = day * 15;
	var month = day * 30;
	var now = new Date().getTime(); //获取当前时间戳
	 var diffValue = now - dateTimeStamp;  // 时间差
	if(diffValue < 0){return;}
	var monthC =diffValue/month;
	var weekC =diffValue/(7*day);
	var dayC =diffValue/day;
	var hourC =diffValue/hour;
	var minC =diffValue/minute;
	if(monthC>=1){
		result="" + parseInt(monthC) + "月前";
	}
	else if(weekC>=1){
		result="" + parseInt(weekC) + "周前";
	}
	else if(dayC>=1){
		result=""+ parseInt(dayC) +"天前";
	}
	else if(hourC>=1){
		result=""+ parseInt(hourC) +"小时前";
	}
	else if(minC>=1){
		result=""+ parseInt(minC) +"分钟前";
	}else
	result="刚刚";
	return result;
}
 

var browser = {
	versions: function() {
	  var u = navigator.userAgent;
	  return {
			  trident: u.indexOf('Trident') > -1, //IE内核
			  presto: u.indexOf('Presto') > -1, //opera内核
			  webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
			  gecko: u.indexOf('Firefox') > -1, //火狐内核
			  mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
			  ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
			  android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
			  iPhone: u.indexOf('iPhone') > -1 , //iPhone
			  iPad: u.indexOf('iPad') > -1, //iPad
			  webApp: u.indexOf('Safari') > -1 //Safari
		  };
	  }()
  }
  
  if (browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad) {
	  alert('移动端');
  }


  //判断是否微信浏览器
function isWeiXin() {
	var ua = window.navigator.userAgent.toLowerCase();
	console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
	if (ua.match(/MicroMessenger/i) == 'micromessenger') {
	return true;
	} else {
	return false;
	}
	}
	if(isWeiXin()){
	console.log(" 是来自微信内置浏览器")
	}else{
	console.log("不是来自微信内置浏览器")
	}